package service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import entity.*;
import mapper.ServiceMapper;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@org.springframework.stereotype.Service
public class SServiceImpl implements SService {
    @Autowired
    private ServiceMapper serviceMapper;
    @Override
    public PageInfo<Service> selectByPage(LayRequest layRequest) {
        PageHelper.startPage(layRequest.getPage(),layRequest.getLimit());
        List<Service> services = serviceMapper.selectByMap(layRequest.getParams());
        return new PageInfo<>(services);
    }

    @Override
    public boolean insert(Service service) {
        return serviceMapper.insert(service)>0?true:false;
    }

    @Override
    public boolean update(Service service) {
        return serviceMapper.udpate(service)>0?true:false;
    }

    @Override
    public boolean batchDelete(Integer[] ids) {
        return serviceMapper.batchDelete(ids)>0?true:false;
    }

    @Override
    public List<Service> selectWithCustomer() {
        return serviceMapper.selectWithCustomer();
    }

    @Override
    public Service selectById(Integer id) {
        return serviceMapper.selectById(id);
    }

    @Override
    public List<Service> selectUserAccount() {
        return serviceMapper.selectUserAccount();
    }

    @Override
    public boolean insertWithHandler(Service_Transfer service_transfer) {
        return serviceMapper.insertWithHandler(service_transfer)>0?true:false;
    }

    @Override
    public boolean updateByNewanagerId(Integer new_manager_id,Integer service_id) {
        return serviceMapper.updateByNewanagerId(new_manager_id,service_id)>0?true:false;
    }

    @Override
    public Users selectByUserId(Integer id) {
        return serviceMapper.selectByUserId(id);
    }

    @Override
    public Customer selectByCustomerId(Integer id) {
        return serviceMapper.selectByCustomerId(id);
    }


    @Override
    public PageInfo<CustomerCare> customerCareList(LayRequest layRequest) {
        PageHelper.startPage(layRequest.getPage(),layRequest.getLimit());
        List<CustomerCare> customerCares = serviceMapper.customerCareList(layRequest.getParams());
        return new PageInfo<>(customerCares);
    }

    @Override
    public Service selectByServiceId(Integer id) {
        return serviceMapper.selectByServiceId(id);
    }

    @Override
    public List<Service> selectWithCustomerName() {
        return serviceMapper.selectWithCustomerName();
    }

    @Override
    public Service selectByHandler(Integer handler) {
        return serviceMapper.selectByHandler(handler);
    }

    @Override
    public Service selectCustomer_id(Integer customer_id) {
        return serviceMapper.selectCustomer_id(customer_id);
    }

    @Override
    public boolean handleService(Service service) {
        return serviceMapper.handleService(service)>0?true:false;
    }

    @Override
    public Service selectByServiceIdWithCustomerId(Integer id) {
        return serviceMapper.selectByServiceIdWithCustomerId(id);
    }
    @Override
    public List<Service_Transfer> selectServiceTransfer(Integer id) {
        return serviceMapper.selectServiceTransfer(id);
    }
}
